<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$Think.config.site.title} - 主页</title>
    <meta name="keywords" content="{$Think.config.site.keywords}">
    <meta name="description" content="{$Think.config.site.description}">
    <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/animate.css" rel="stylesheet">    
    <link href="{$Think.config.site.resource_url}css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.css?v=4.1.0" rel="stylesheet">
    <style>
        #listtable .fa{    cursor: pointer;color: #1ab394;margin-right: 1em;}
    </style>
</head>

<body >
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
            <style type="text/css">.col-sm-12 label{ font-weight:300; }</style>
                <div class="ibox float-e-margins">
                    <div class="">
                        <h5>{:lang('商户列表')}</h5>
                    </div>
                    <div class="row ibox-title">
                    <form action="" method="post" name="leaseorder">
                        <!--<label><button type="button"  class="btn btn-sm btn-primary" id="addBtn"> {:lang('添加商户')}</button>　　</label>-->
                        <label >{:lang('商铺名称')}：</label>
                        <label ><input type="text" class="input-sm form-control" name="name" value="{$name ?? ''}"  aria-controls="" placeholder="{:lang('输入')}{:lang('商铺名称')}"></label>　　 　　　 　　
                        <!--<label>{:lang('所在区域')}：</label>-->
                        <!--<label ><input type="text" class="input-sm form-control" name="area" value="{$area ?? ''}" aria-controls="" placeholder="{:lang('输入')}{:lang('所在区域')}"></label>-->
                        <label><button type="submit" class="btn btn-sm btn-primary"> {:lang('提交')}</button> </label>
                        </form>
                    </div>
                    <div class="ibox-content">

                        <table class="table table-hover" id="listtable">
                            <thead>
                                <tr>
                                    <th>{:lang('商铺名称')}</th>
                                    <th>{:lang('绑定手机')}</th>
                                    <th>{:lang('人均消费')}</th>
                                    <th>{:lang('详细地址')}</th>
                                    <th>{:lang('营业时间')}</th>
                                    <th>{:lang('佣金比例')}</th>
                                    <th>{:lang('设置单价')}</th>
                                    <th>{:lang('添加时间')}</th>
                                    <th>{:lang('用户状态')}</th>
                                    <th>{:lang('操作')}</th>
                                </tr>
                            </thead>
                            <tbody>
                            <?php
                                 function parseTime($time) {
                                                        $per = intval($time / 100);
                                                    $last = intval($time %100);

                                                if (strlen($per) == 1) {
                                                    $per = '0'.$per;
                                                }
                                            if (strlen($last) == 1) {
                                     $last = '0'.$last;
                                         }
                                    return $per.':'.$last;
                                }

                            ?>
                            {volist name="list" id="v"}
                                <tr data-id="{$v.id}">
                                    <td>{$v.name}</td>
                                    <td>{$v.mobile}</td>
                                    <td>{$v.averageprice}元</td>
                                    <td>{$v.addr}</td>
                                    <td>
                                        <?php
                                        $shopstart = parseTime($v['shopstart']);
                                        $shopend = parseTime($v['shopend']);
                                        echo $shopstart.'~'.$shopend;
                                        ?>
                                    </td>
                                    <td style="color:red">{$v.brokerage}%</td>
                                    <td style="color: red">{$v.per_price}/小时</td>
                                    <td>
                                        <?php
                                        if ($v['create_time']) {
                                            echo date('Y-m-d H:i', $v['create_time']);
                                        }
                                        ?>
                                    </td>
                                    <td>{$status[$v['status']]}</td>
                                    <td>
                                        <i class="fa fa-edit"> {:lang('修改')}</i>
                                        <i class="fa fa-battery-1"> {:lang('设备详情')} </i>
                                        <?php
                                        if ($v['status'] == 1) {
                                    ?>
                                        <i class="fa fa-forbiddent change_status"  data-id="{$v.id}" style="color:red"> {:lang('禁用')} </i>
                                        <?php }else { ?>
                                        <i class="fa fa-forbiddent change_status"  data-id="{$v.id}"> {:lang('启用')} </i>
                                        <?php }?>

                                    </td>
                                </tr> 
                            {/volist}
                            </tbody>
                        </table>
                    </div>

                    <div class="row">
                        <div class="row">
                        <div class="col-sm-5">
                            <div class="dataTables_info" id="DataTables_Table_0_info" role="alert" aria-live="polite" aria-relevant="all"></div>
                        </div>
                        <div class="col-sm-7">
                            <div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
                                {$list->render()}
                            </div>
                        </div>
                    </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
    <script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
    <script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.5"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/peity/jquery.peity.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/iCheck/icheck.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>

    <script>

    var layer_font;
    var $editTr;
        $(document).ready(function() {
            $("#addBtn").bind("click",function(){
                layer_font = layer.open({
                  type: 2,
                  title: "{:lang('添加商户信息')}",
                  shadeClose: true,
                  shade: 0.8,
		          area: ['90%', '90%'],
                  content: '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Seller/add' //iframe的url
                });
            });

            //修改按钮
            $("#listtable").on("click",".fa-edit",function(){
                $editTr = $(this).closest("tr");
                var id = $editTr.data("id");
                layer_font = layer.open({
                  type: 2,
                  title: "{:lang('修改商户信息')}",
                  shadeClose: true,
                  shade: 0.8,
                  area: ['90%', '90%'],
                  content: '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Seller/add?id='+id //iframe的url
                });
            })

            //设备详情
            $("#listtable").on("click",".fa-battery-1",function(){
                $editTr = $(this).closest("tr");
                var id = $editTr.data("id");
                layer_font = layer.open({
                  type: 2,
                  title: "{:lang('查看设备信息')}",
                  shadeClose: true,
                  shade: 0.8,
                  area: ['80%', '90%'],
                  content: '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Equipment/index?sid='+id //iframe的url
                });
            })

            $(".change_status").on("click",function(){
                var id = $(this).attr('data-id');
                layer.confirm("{:lang('确定要更改状态吗？')}", {
                        btn: ["{:lang('确定')}","{:lang('取消')}"], //按钮
                        shade: false //不显示遮罩
                    }, function(){
                        //确定禁用
                        $.ajax({
                            type : 'POST',//delete
                            url : '<?php echo \think\Request::instance()->root(); ?>/ausadmin/seller/change_status?id='+id,
                            dataType : 'json',
                            data : {id:id},
                            async:false,
                            success : function(result) {
                                if(0 === result.code) {
                                    layer.msg(result.msg, {icon: 1});
                                    window.location.reload();
                                }  else  {
                                    layer.msg(result.msg, {icon: 5});
                                }
                            },
                            error : function(){
                                res = false;
                                layer.msg("{:lang('服务器错误！请稍后重试')}", {icon: 2});
                            }
                        })
                    },
                    function(){

                    });

            });



            //删除按钮注册
            $("#listtable").on("click",".fa-trash-o",function(){
                var $tr = $(this).closest("tr");
                var id = $tr.data("id");
                layer.confirm("{:lang('确定要删除？')}", {
                    btn: ["{:lang('确定删除')}","{:lang('不删除')}"], //按钮
                    shade: false //不显示遮罩
                }, function(){
                    //确定删除
                    $.ajax({
                        type : 'POST',//delete
                        url : '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Seller/delete?id='+id,
                        dataType : 'json',
                        data : {id:id},
                        async:false,
                        success : function(result) {
                            //layer.close(layer1);
                            if(0 === result.code) {
                                $tr.remove();
                                layer.msg(result.msg, {icon: 1});
                            }  else  {
                                //删除失败
                                layer.msg(result.msg, {icon: 5});
                            }
                        },
                        error : function(){
                            res = false;
                            layer.msg("{:lang('服务器错误！请稍后重试')}", {icon: 2});
                        }
                    })
                },
                function(){
                    
                });

                
            });
        }); 
    </script>
    <!--统计代码，可删除-->

</body>

</html>
